package com.moeciyo.android.moeciyo.fragment;

import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.widget.TextView;

import com.moeciyo.android.moeciyo.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import cn.droidlover.xdroidmvp.base.XFragmentAdapter;
import me.weyye.library.colortrackview.ColorTrackTabLayout;

public class HomeFragment extends BaseFragment{

    @BindView(R.id.title_right)
    TextView sousuo;
    @BindView(R.id.title_name)
    TextView title_name;
    @BindView(R.id.tabLayout)
    ColorTrackTabLayout tab;
    @BindView(R.id.viewPager)
    ViewPager vpage;

    //名称
    String[] titles = {"首页", "干货", "妹子"};
    //页面
    private List<Fragment> listData = new ArrayList<>();

    XFragmentAdapter adapter;

    public static HomeFragment newInstance() {
        Bundle args = new Bundle();
        HomeFragment fragment = new HomeFragment();
        return fragment;
    }

    @Override
    protected int setLayoutId() {
        return R.layout.fragment_home;
    }

    @Override
    protected void initData(){
        listData.clear();
        listData.add(RecommendFragment.newInstance());
        listData.add(RecommendFragment.newInstance());
        listData.add(RecommendFragment.newInstance());
        if (adapter == null) {
            adapter = new XFragmentAdapter(getChildFragmentManager(), listData, titles);
        }
        vpage.setAdapter(adapter);
        vpage.setOffscreenPageLimit(3);
        tab.setupWithViewPager(vpage);
    }

}
